package com.yanqu.road.server.cmd.beautyescort;

import com.yanqu.road.pb.beautyescort.BeautyEscortProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.beautyescort.BeautyEscortModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_BEAUTY_ESCORT_VIEW_USER, desc = "查看玩家（从战报）")
public class BeautyEscortViewUserCmd extends AbstractCommand {


    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        boolean groupOpen = player.getModule(BeautyEscortModule.class).systemOpen();
        if(groupOpen){
            BeautyEscortProto.BeautyEscortViewUserReqMsg reqMsg = BeautyEscortProto.BeautyEscortViewUserReqMsg.parseFrom(packet.getBytes());
            player.sendPacket(Protocol.C_BEAUTY_ESCORT_VIEW_USER, reqMsg.toBuilder());
        }else {
            ret = GameErrorCode.E_BEAUTY_ESCORT_SYSTEM_NO_OPEN;
        }
    }

    @Override
    public void sendData(GamePlayer player) {
        if(ret != 0){
            BeautyEscortProto.BeautyEscortViewUserRespMsg.Builder respMsg = BeautyEscortProto.BeautyEscortViewUserRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(Protocol.U_BEAUTY_ESCORT_VIEW_USER, respMsg);
        }
    }
}
